package cn.ezios.huo.system.dao.service.impl;

import cn.ezios.huo.system.dao.dto.SysUserAuthLogDTO;
import cn.ezios.huo.system.dao.vo.SysUserAuthLogVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.ezios.huo.system.dao.domain.SysUserAuthLog;
import cn.ezios.huo.system.dao.service.SysUserAuthLogService;
import cn.ezios.huo.system.dao.mapper.SysUserAuthLogMapper;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

/**
 * @author 王坚
 * @description 针对表【sys_user_auth_log(系统用户认证记录表)】的数据库操作Service实现
 * @createDate 2024-07-17 09:49:16
 */
@Service
public class SysUserAuthLogServiceImpl extends ServiceImpl<SysUserAuthLogMapper, SysUserAuthLog>
        implements SysUserAuthLogService {

    /**
     * 分页查询
     *
     * @param current
     * @param size
     * @param dto
     * @return
     */
    @Override
    public IPage<SysUserAuthLogVO> queryPage(Integer current, Integer size, SysUserAuthLogDTO dto) {
        Page<SysUserAuthLog> page = Page.of(current, size);
        return lambdaQuery()
                .like(dto.getUserId() != null && !dto.getUserId().isBlank(), SysUserAuthLog::getUserId, dto.getUserId())
                .page(page)
                .convert(origin -> {
                    SysUserAuthLogVO vo = new SysUserAuthLogVO();
                    BeanUtils.copyProperties(origin, vo);
                    return vo;
                });
    }
}




